package com.amumu.drama.common.modules.delivery.handler.impl;

import com.amumu.drama.common.constant.DeliveryProviderEnum;
import com.amumu.drama.common.constant.DeliveryStatusEnum;
import com.amumu.drama.common.constant.OrderTypeEnum;
import com.amumu.drama.common.modules.delivery.config.DeliveryConfig;
import com.amumu.drama.common.modules.delivery.dto.DeliveryStatusResp;
import com.amumu.drama.common.modules.delivery.dto.req.DeliveryHandleDTO;
import com.amumu.drama.common.modules.delivery.handler.DeliveryHandler;
import com.amumu.drama.common.modules.order.dto.OmsOrderDetail;
import com.google.common.collect.Lists;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author sunzhuang
 * @date 2024/6/27 09:06
 * @slogan 天下风云出我辈, 一入代码岁月催
 * @desc 人工发货实现
 */

@Service
public class ManualDeliveryHandler implements DeliveryHandler {
    /**
     * 发货渠道
     */
    @Override
    public List<String> type() {
        return Lists.newArrayList(
                DeliveryConfig.getDeliveryType(OrderTypeEnum.MANUAL_DELIVERY, DeliveryProviderEnum.MANUAL),
                DeliveryConfig.getDeliveryType(OrderTypeEnum.INTERFACE2MANUAL_DELIVERY, DeliveryProviderEnum.MANUAL)
        );
    }

    /***
     * 处理发货（开始发货）
     * @param orderId
     * @param orderDetail
     */
    @Override
    public DeliveryStatusResp delivery(Long orderId, OmsOrderDetail orderDetail, DeliveryHandleDTO deliveryHandleDTO) {
        DeliveryStatusResp resp = new DeliveryStatusResp();
        if (deliveryHandleDTO == null) {
            resp.setDeliveryStatusEnum(DeliveryStatusEnum.FAIL);
            resp.setMsg("发货订单号不能为空");
        }
        resp.setDeliveryStatusEnum(DeliveryStatusEnum.DELIVERY);
        resp.setDeliverySn(deliveryHandleDTO.getDeliverySn());
        return resp;
    }


}
